#!/bin/sh
# --------------------------------------------
# Linuxrules + dzen2 Basic example with colors
# --------------------------------------------
# Last Revision:	Sat Oct 23 2010, 05:34:02
#
#  Copyright (C) 2010 Mario García H.

#  "THE BEER-WARE LICENSE" (Revision 42):
#  <code933k (AT) gmail> wrote this file. As long as you retain
#  this notice you can do whatever you want with this stuff.

#  If we meet some day, and you think this stuff is worth it,
#  you can buy me a BEER in return, Mario García H.

#  THIS IS FREE SOFTWARE PROVIDED AS-IS
#  THERE IS NO WARRANTY, TO THE EXTENT PERMITTED BY LAW.


# Get new data every time the loop starts
while eval $(linuxrules)
do
	OUTPUT=''
# Issue linuxrules firstly to know what parameters
# apply for your system so you can use them inside
# scripts. We are lucky that every computer has a
# CPU0 (1 cpu or the first one of them) ;)

# Beautify output
	if test $CPULOAD0 -gt 80
	then
		OUTPUT="$OUTPUT^fg()cpu1: ^fg(red)$CPULOAD0^fg()"
	elif test $CPULOAD0 -gt 40
	then
		OUTPUT="$OUTPUT^fg()cpu1: ^fg(orange)$CPULOAD0^fg()"
	else
		OUTPUT="$OUTPUT^fg()cpu1: ^fg(green)$CPULOAD0^fg()"
	fi
# Show what was processed before
	echo "$OUTPUT"

# Wait for a second
	sleep 1

# output this to dzen2 and start again
done | dzen2
